/**
 * Created by GSY on 16/9/27.
 */
/**
 * Created by Administrator on 2016/8/22.
 */
NodeList.prototype.forEach = Array.prototype.forEach;

var path_change = 'http://pm.ht-home.cn/api/others/getDesignRectificationForshare.json?projectId=' + window.currentProjectId;
var xhr_change = null;
var photosUrl_change = [];

if (window.XMLHttpRequest) {
    // 非IE内核
    xhr_change = new XMLHttpRequest();
}

xhr_change.open('get', path_change, true);
xhr_change.send(null);
xhr_change.onreadystatechange = function () {
    if (xhr_change.readyState === 4) {
        if (xhr_change.status === 200) {
            var jsonData_change = JSON.parse(xhr_change.responseText);
            BindData_change(jsonData_change);
        }
    }
};


function BindData_change(jsonData) {
    document.getElementById("need-change").innerHTML = typeof jsonData.data.reformInfo === 'undefined' ? ''  : jsonData.data.reformInfo;
    document.getElementById("date-change").innerHTML = typeof jsonData.data.reformDate === 'undefined' ? ''  : jsonData.data.reformDate.substring(0, jsonData.data.reformDate.indexOf(" "));
    document.getElementById("result-change").innerHTML = typeof jsonData.data.reformResult === 'undefined' ? ''  : jsonData.data.reformResult;

    var photo_change = document.getElementById("photo-change");
    if (jsonData.data.classList) {
        var photos = jsonData.data.classList[0];
        if (photos.ZGPZ.length > 0) {
            for (var i = 0; i < photos.ZGPZ.length; i++) {
                var newNode = document.createElement('img');
                var type = 'ZGPZ';
                newNode.setAttribute("onclick", "useHammer_change(event," + i + ",'" + type + "')");
                newNode.style = 'width: 32%;margin:margin: 1px 0 1px 1%';
                newNode.className = 'image';
                newNode.src = photos.ZGPZ[i].smallImageUrl;
                photosUrl_change[i] = photos.ZGPZ[i].largeImageUrl;
                newNode.style.height = newNode.style.width;
                photo_change.appendChild(newNode);
            }
        } else {
            photo_change.style.display = 'none';
        }
    } else {
        photo_change.style.display = 'none';
    }

}

function useHammer_change(e, index, type) {
    //images: 图片url数组men
    hammerMask_report.style.top = document.body.scrollTop + "px";
    hammerBg_report.style.top = document.body.scrollTop + "px";

    switch (type) {
        case "ZGPZ": window.showHammer_html(photosUrl_change, index); break;
    }
}
